$(function() {
	resizeIframe();
	$(".side-bar").hide();
	switchPage("首页")
})

var tabChooseOpen = ""; //记录选择并打开的菜单

/**
 * 设置iframe页面高度
 */
function resizeIframe() {
	var height = window.innerHeight;
	$(".iframe-div").css("height", height * 0.94 - 30);
}

/**
 * 点击菜单
 * @param {Object} e
 */
function clickTabMenu(e) {
	$(".side-bar").hide();
	$(".tab-button").css("color", "#fff");
	var menu = $(e).text();
	if(tabChooseOpen != "" && tabChooseOpen == menu){
		tabChooseOpen = "";
		return;
	}
	tabChooseOpen = menu;
	$(e).css("color", "#00EEFF");
	showSideMenu(menu);
}

/**
 * 展示侧边菜单栏
 * @param {Object} menu
 */
function showSideMenu(menu) {

	if(menu == "订单") {
		$("#orderSideMenu").show();
	} else if(menu == "数据") {
		$("#dataSideMenu").show();
	} else if(menu == "报表") {
		$("#chatSideMenu").show();
	} else if(menu == "商城") {
		$("#storeSideMenu").show();
	} else if(menu == "代理") {
		$("#agentSideMenu").show();
	} else if(menu == "工具") {
		$("#toolSideMenu").show();
	}
}

/**
 * 点击侧边菜单栏
 */
function clickSideMenu(e) {
	var menu = $(e).text();
	switchPage(menu);
}

/**
 * 切换页面
 * @param {Object} menu
 */
function switchPage(menu){
	$(".tab-button").css("color", "#fff");
	var page = getPageByMenu(menu);
	$(".side-bar").hide();
	if(page == "") {
		tabChooseOpen="";
		return;
	}
	$("#tabIframe").attr("src", page);
	$(".title-box").text(tabChooseOpen + "/"+ menu);
	tabChooseOpen="";
}
function getPageByMenu(menu) {
	var page = "";
	switch(menu) {
		case "未发货":
			page = "order/un_send.html";
			break;
		case "创建":
			page = "order/create.html";
			break;
		default:
		page = "welcom.html";
	}
	return page;
}
